package emas.shared;

import java.io.Serializable;
import java.util.ArrayList;

public class Location implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3115707608315603774L;
	private int id;
	private String name;
	private String ip;
	private String address;
	private String comment;
	private String password;
	private ArrayList<SensorData> last250DataEntry;
	private String weatherImageURL;
	private double lat;
	private double lng;

	public Location(int id, String name, String ip, String address,
			String comment, String password, double lat, double lng) {
		this.id = id;
		this.name = name;
		this.ip = ip;
		this.address = address;
		this.comment = comment;
		this.password = password;
		this.lat = lat;
		this.lng = lng;
		last250DataEntry = new ArrayList<SensorData>();
	}
	
	public Location(int id, String name, String ip, String address,
			String comment, String password) {
		this.id = id;
		this.name = name;
		this.ip = ip;
		this.address = address;
		this.comment = comment;
		this.password = password;
		last250DataEntry = new ArrayList<SensorData>();

	}

	public Location() {

	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public ArrayList<SensorData> getLast250DataEntry() {
		return last250DataEntry;
	}

	public void setLast250DataEntry(ArrayList<SensorData> last250DataEntry) {
		this.last250DataEntry = last250DataEntry;
	}

	public String getWeatherImageURL() {
		return weatherImageURL;
	}

	public void setWeatherImageURL(String weatherImageURL) {
		this.weatherImageURL = weatherImageURL;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public SensorData getLastDataEntry() {
		if (last250DataEntry != null) {
			if (!last250DataEntry.isEmpty()) {
				SensorData lastDataEntry = last250DataEntry.get(0);
				return lastDataEntry;
			} else {
				return null;
			}
		} else {
			return null;
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Location other = (Location) obj;
		if (id != other.id)
			return false;
		return true;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}

}
